home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13232 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  44 lines

  1. Path: news.fsu.edu!sed!lloyd
  2. From: lloyd@sed.cs.fsu.edu (Justin C Lloyd)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: PLEASE HELP!!!
  5. Date: 5 Apr 1996 11:44:57 GMT
  6. Organization: FSU Computer Science Department
  7. Message-ID: <4k313p$6oe@news.fsu.edu>
  8. References: <4k25rv$l4s@netnews.ntu.edu.tw>
  9. NNTP-Posting-Host: sed.cs.fsu.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. On 5 Apr 1996 03:59:59 GMT, b3503104 (b3503104@cc.ntu.edu.tw) wrote:
  13. ** Please help!
  14.  
  15. **  How can I write a program in C to have the similar function as "dir" in
  16. ** DOS?  ??  (that is to LIST the files)
  17.  
  18. ** Any suggestions or hints will be very helpful and appreciated!!
  19.  
  20. #include <stdio.h>
  21.  
  22. int main(void)
  23. {
  24.     system("DIR");
  25.     return (0);
  26. }
  27.  
  28. Sorry, I couldn't resist.  But seriously folks, for a good example of this,
  29. check out Stevens' book "Advanced Programming in the Unix Environment".  He
  30. has an example of a directory tree walking program, which wouldn't be
  31. difficult to port over to DOS.  I had to use this to implement "ls" in a
  32. Unix programming class, which wasn't too hard (minus having to do the damn
  33. columns and spacing for 'ls' with no arguments!!!!!)
  34.  
  35. Also, check out dir.h in your compiler's include/sys directory (or is it
  36. dirent.h, I can never keep those straight.)
  37.  
  38. JcL
  39. --
  40. %%%% Justin Lloyd %% lloyd@cs.fsu.edu %% http://www.cs.fsu.edu/~lloyd %%%%
  41. %%%  in the face of the blinding sun i wake  :     Sarah McLachlan     %%%
  42. %%%  only to find that heaven is a stranger  :     -- Drawn to --      %%%
  43. %%%  place than the world i've left behind   :     - the Rhythm -      %%%
  44.